
module.exports = class extends baseController{
    constructor(){
        super();
        this.adminUserLogic=this.loadLogic('iframe/admin-user');
        this.router.post('/login',this.login.bind(this));
        return this.router;
    }

    init(){
        return new this();
    }

    async login(req,res){
        let Result={};
        try{
            let QueryModel = {};
            QueryModel.UserName = req.body.UserName || '';
            QueryModel.Pwd = req.body.Pwd || '';
            QueryModel.PartnersId = req.body.PartnersId || -1;
            QueryModel.Type = req.body.Type || 0;
            QueryModel.Sign=req.body.Sign || 'system';
    
            if (QueryModel.UserName === '' || QueryModel.Pwd === '') {
                ret = this.Error('用户名和密码不能为空');
            };
            let ret = await  this.adminUserLogic.login(QueryModel);
            if(ret && ret.Result){
                Result=this.Success(1,ret.Data);
            }else{
                Result = this.Error(ret.Msg);
            }
        }catch(err){
            Result =this.Error("登录失败",err);
        }
        res.json(Result);
       
    }
}

